import service from '@/service';

export default {
	state: {
		stepToken: null,
		stepUserInfo: {},
		hdyxRiskSetting: {}
	},
	mutations: {
		setStepToken(state, value) {
			state.stepToken = value;
		},
		setStepUserInfo(state, value) {
			state.stepUserInfo = value;
		},
		setHdyxRiskSetting(state, value) {
			state.hdyxRiskSetting = value;
		}
	},
	actions: {
		// 设置token
		async stepToken({ commit }, obj) {
			uni.setStorageSync('stepToken', obj.token)
			commit('setStepToken', obj.token);
		},
		// 获取用户信息
		async getStepUserInfo({ commit }) {
			const userInfo = await service.common.step.userInfo();
			commit('setStepUserInfo', userInfo);
		},
		// 获取风控配置
		async getHdyxRiskSetting({ commit }) {
			const hdyxRiskSetting = await service.common.step.hdyxRiskSetting({
				noToken: true
			});
			commit('setHdyxRiskSetting', hdyxRiskSetting);
		}
	}
};
